package demo;

import com.huaweicloud.sdk.cbs.v1.CbsClient;
import com.huaweicloud.sdk.cbs.v1.model.ExecuteQaChatRequest;
import com.huaweicloud.sdk.cbs.v1.model.ExecuteQaChatResponse;
import com.huaweicloud.sdk.cbs.v1.model.PostRequestsReq;
import com.huaweicloud.sdk.core.auth.ICredential;
import com.huaweicloud.sdk.core.auth.BasicCredentials;
import com.huaweicloud.sdk.core.http.HttpConfig;
import com.huaweicloud.sdk.core.region.Region;

public class ExecuteQaChatSolution {
	public static void main(String[] args) {
		String ak = "Ak"; // 配置账户的AK SK 信息
		String sk = "Sk";
		String iamEndpoint = "iamEndpoint"; // 获取iam 站点 https://support.huaweicloud.com/api-iam/iam_16_0005.html
		String endpoint = "endpoint";  // 获取cbs 站点信息 https://support.huaweicloud.com/api-cbs/cbs_03_0102.html
		HttpConfig config = new HttpConfig(); // 网络配置信息
		config.withIgnoreSSLVerification(true);
		ICredential auth = new BasicCredentials()
		  .withIamEndpoint(iamEndpoint)
		  .withAk(ak)
		  .withSk(sk);
		CbsClient client = CbsClient.newBuilder()
		  .withCredential(auth)
		  .withHttpConfig(config)
		  .withRegion(new Region("cn-north-4", endpoint))
		  .build();
		ExecuteQaChatRequest request = new ExecuteQaChatRequest(); // 设置请求问题 相关参数可以参考：https://support.huaweicloud.com/api-cbs/cbs_03_0115.html
		PostRequestsReq body = new PostRequestsReq();
		body.setQuestion("你好");
		request.withBody(body);
		request.setQabotId("botid"); // 设置botId,可以参考前提条件的获取botid方法
		ExecuteQaChatResponse response = client.executeQaChat(request);
		System.out.println(response.toString());
	}
}
